<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
	<link rel="stylesheet" href="/css/jquery.tooltip.css" />
	<script src="/js/jquery.tooltip.min.js" type="text/javascript"></script>
	<!-- 验证 -->
	<script type="text/javascript" charset="UTF-8" src="/js/formValidator_min.js" charset="UTF-8"></script>
	<script type="text/javascript" charset="UTF-8" src="/js/formValidator.js" charset="UTF-8"></script>
	<script type="text/javascript" charset="UTF-8" src="/js/formValidatorRegex.js" charset="UTF-8"></script>
	<!-- 数字验证 -->
	<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>		
	<script language="javascript"><!--
	$().ready( function() {
			//$.formValidator.initConfig({formid:"specForm",onerror:function(msg){alert(msg)},onsuccess:function(){return true;}});
			//$("#spcName").formValidator({onfocus:"請輸入規格名稱",oncorrect:"規格名稱輸入正確"}).inputValidator({min:2,max:100,onerror:"規格名稱须介于2-100个字元之间且不能为空值"});
			$("tr[id*='tdDesc_']").tooltip();
			$("input[id*='spcReverseInventory_']").each(function(i,item){
				$("input[id*='spcReverseInventory_']").numeric();
				});
			$("input[id*='spcMaxCountPerOrder_']").each(function(i,item){
				$("input[id*='spcMaxCountPerOrder_']").numeric();
				});
			$("input[id*='spcMinCountPerOrder_']").each(function(i,item){
				$("input[id*='spcMinCountPerOrder_']").numeric();
				});
			$("input[id*='spcSafeInventory_']").each(function(i,item){
				$("input[id*='spcSafeInventory_']").numeric();
				});
			$("#spcReverseInventory").numeric();
			$("#spcMaxCountPerOrder").numeric();
			$("#spcMinCountPerOrder").numeric();
			$("#spcSafeInventory").numeric();
			$("#submit_button").click(function(){
				try {								
					$("input[id*='spcName_']").each(function(i,item){					
						if(item.value == ""){
							alert("请输入规格名称");
							item.focus();
							throw item;
						}
					});
					$("input[id*='spcReverseInventory_']").each(function(i,item){
						if(item.value == ""){
							alert("请输入庫存保留量");
							item.focus();
							throw item;
						}
					});
					$("input[id*='spcMaxCountPerOrder_']").each(function(i,item){
						if(item.value == ""){
							alert("请输入订单单笔最大可销售数量");
							item.focus();
							throw item;
						}
					});
					$("input[id*='spcMinCountPerOrder_']").each(function(i,item){
						if(item.value == ""){
							alert("请输入订单单笔最小可销售数量");
							item.focus();
							throw item;
						}
					});
					$("input[id*='spcSafeInventory_']").each(function(i,item){
						if(item.value == ""){
							alert("请输入安全库存量");
							item.focus();
							throw item;
						}
					});		
				}catch(e){
					return false;
				}
				if ($("#spcName").val() != "" ){
					if ($("#spcReverseInventory").val() == "" ){
						alert("请输入庫存保留量.");
						$("#spcReverseInventory").focus();
						return false;
					}
					if ($("#spcMaxCountPerOrder").val() == "" ){
						alert("订单单笔最大可销售数量.");
						$("#spcMaxCountPerOrder").focus();
						return false;
					}
					if ($("#spcMinCountPerOrder").val() == "" ){
						alert("请输入订单单笔最小可销售数量.");
						$("#spcMinCountPerOrder").focus();
						return false;
					}
					if ($("#spcSafeInventory").val() == "" ){
						alert("请输入安全库存量.");
						$("#spcSafeInventory").focus();
						return false;
					}					
				}
				$("#specForm").submit();
			});

	});
--></script>			
<h1>提报商品管理<br/>
<div class="f-link">
<a href="edit.do?productId=${productId}" />编辑商品</a>
<a href="<%=ServerValue.getMidContextPath()%>/image/editPropose.do?productId=${productId}" />上传图档</a>
<a href="<%=ServerValue.getMidContextPath()%>/proposeProductApprove/list.do">回列表页</a>
</div>
</h1>
<s:form action="saveSpec.do" method="post" id="specForm">
<table class="tb-data" width="100%">
<TR><TH>商品名称（商品编号）</TH></TR>
<tr><td> ${proposeProduct.name}(${productId})</td></tr>
</table>
<table class="tb-data" width="100%">	
 <thead>                   
   <tr>
     <th>*规格名称<BR />(例如:蓝-XL,..)<BR />长度:25</th>
    <th>规格料号<BR />(供应商自行管理之编号)<BR />长度:20</th>
    <th>规格条码<BR />(国际标准bar code)<BR />长度:20</th>
    <th>*库存保留量<BR />(供退换货使用)</th>
    <th>*订单单笔<BR />最大可销售数量</th>
    <th>*订单单笔<BR />最小可销售数量</th>
    <th>*安全库存量</th>
    <th>*规格状态</th>
    <!-- <th>*排序</th> -->
     <th>删除</th>
   </tr>
 </thead>
 <tbody>
 	<c-rt:forEach items="${proposeSpecifications}" var="specification" varStatus="rows_index">            
		<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}" id="tdDesc_${rows_index.count}" title="建立者:${specification.createUser} 建立日期:${specification.createDate}<br/>修改者:${specification.modifyUser} 修改日期:${specification.modifyDate}">	
		 	<td>
		 		<input type="hidden" name="spcId" value="${specification.id}" />
		 		<input type="text" name="spcName" id="spcName_${rows_index.count}" size="15" maxlength="25" value="${specification.name}" />
		 	</td>
      <td><input type="text" name="spcCode" id="spcCode" size="10" maxlength="20" value="${specification.specCode}" /></td>
      <td><input type="text" name="spcBarCode" id="spcBarCode" size="10" maxlength="20" value="${specification.barCode}" /></td>
      <td><input type="text" name="spcReverseInventory" maxlength="8" id="spcReverseInventory_${rows_index.count}" size="5" value="${specification.reverseInventory}" /></td>
      <td><input type="text" name="spcMaxCountPerOrder" maxlength="8" id="spcMaxCountPerOrder_${rows_index.count}" size="5" value="${specification.maxCountPerOrder}" /></td>
      <td><input type="text" name="spcMinCountPerOrder" maxlength="8" id="spcMinCountPerOrder_${rows_index.count}" size="5" value="${specification.minCountPerOrder}" /></td>
      <td><input type="text" name="spcSafeInventory" maxlength="8" id="spcSafeInventory_${rows_index.count}" size="5" value="${specification.safeInventory}" /></td>
      <td>
       	<select name="specStatus">
       		<c-rt:forEach items="${specStatusMenu.options}" var="op">
       			<option value="${op.key}" ${op.key eq specification.specStatus ? "selected=selected" : ""}>${op.value.name}</option>
       		</c-rt:forEach>
       	</select>
      </td>
			<td><input name="spcDelete" type="checkbox" value="${specification.id}" /></td>
		</tr>
	</c-rt:forEach>       
  <tr class="">
  	<td>
   		<input type="hidden" name="spcId" value="" />
			<input type="text" name="spcName" id="spcName" size="15" maxlength="25" value="" />
		</td>
    <td><input type="text" name="spcCode" id="spcCode" size="10" maxlength="20" value="" /></td>
    <td><input type="text" name="spcBarCode" id="spcBarCode" size="10" maxlength="20" value="" /></td>
    <td><input type="text" name="spcReverseInventory" maxlength="8" id="spcReverseInventory" size="5" value="" /></td>
    <td><input type="text" name="spcMaxCountPerOrder" maxlength="8" id="spcMaxCountPerOrder" size="5" value="" /></td>
    <td><input type="text" name="spcMinCountPerOrder" maxlength="8" id="spcMinCountPerOrder" size="5" value="" /></td>
    <td><input type="text" name="spcSafeInventory" maxlength="8" id="spcSafeInventory" size="5" value="" /></td>
    <td>
    	<select name="specStatus">
				<c-rt:forEach items="${specStatusMenu.options}" var="op">
					<option value="${op.key}">${op.value.name}</option>
				</c-rt:forEach>
			</select>
		</td>
    <td></td>
 	</tr>                        
 </tbody>			
 <tr class="">
	<td>
		<input type="hidden" name="productId" value="${productId}"/>
		<input type="button" id="submit_button" value="储存商品规格"/>
	</td>
 </tr>
</table>
 </s:form>  